package com.example.homework8.bean;


import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

import com.example.homework8.R;
import com.example.homework8.utils.BitmapUtil;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.UUID;

public class RecordInfo {
    public long rowid; // 行号
    public String name; // 名称
    public String info; // 描述
    public String cate; // 分类
    public String createtime; // 价格
    public String username; // 用户名称
    public String imgurl; // 图片
    public String alermtime; // 题型时间


    public RecordInfo() {
        rowid = 0L;
        name = "";
        info = "";
        cate = "";
        SimpleDateFormat ft = new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss");
        createtime =   ft.format(new Date());
    }

    @Override
    public String toString() {
        return "RecordInfo{" +
                "rowid=" + rowid +
                ", name='" + name + '\'' +
                ", info='" + info + '\'' +
                ", cate='" + cate + '\'' +
                ", createtime='" + createtime + '\'' +
                ", username='" + username + '\'' +
                ", imgurl='" + imgurl + '\'' +
                ", alermtime='" + alermtime + '\'' +
                '}';
    }

    // 声明一个商品的名称数组
    private static String[] mNameArray = {
            "买酱油", "放牛",
            "照顾妹妹","读书",
            "烧火", "做饭","买草药","交作业"
    };
    private static String[] alertarray = {
            "2020-10-3 22:10:0","2020-2-3 22:10:0",
            "2020-11-3 22:10:0","2020-4-3 22:10:0",
            "2020-12-3 22:10:0","2020-8-13 22:10:0",
            "2020-9-3 22:10:0","2020-7-23 22:10:0"
    };
    // 声明一个商品的名称数组
    private static  String defaultusername =  "user1";
    // 声明一个商品的描述数组
    private static String[] mInfoArray = new String[]{
            "家里没酱油了!!!",
            "上山放牛咯！！！！",
            "妹妹生病了，照顾妹妹",
            "好好学习",
            "烧掉稻草",
            "做饭给妈妈吃",
            "给妹妹卖草药",
            "上课交作业咯"
    };
    // 声明一个商品的价格数组
     // 声明一个商品的小图数组
    private static int[] mPicArray = {
            R.drawable.d1, R.drawable.d2, R.drawable.d3,
            R.drawable.d4, R.drawable.d5, R.drawable.d6, R.drawable.d7, R.drawable.d8,
    };
    //  mPicArray
    private static int[] mThumbArray = {
            R.drawable.d1, R.drawable.d2, R.drawable.d3,
            R.drawable.d4, R.drawable.d5, R.drawable.d6, R.drawable.d7, R.drawable.d8,
    };
    //  mPicArray
    private static String[] cateArray = {
            "基础日记","基础日记","基础日记","基础日记","基础日记","基础日记", "基础日记","基础日记",
    };
    public static ArrayList<RecordInfo> getDefaultList(Context context, String defname) {
        ArrayList<RecordInfo> RecordList = new ArrayList<RecordInfo>();
        for (int i = 0; i < mNameArray.length; i++) {
            RecordInfo info = new RecordInfo();
            info.name = mNameArray[i];
            info.info = mInfoArray[i];
            info.cate = cateArray[i];
            info.alermtime = alertarray[i];
            Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(),mPicArray[i]);
            String name = UUID.randomUUID().toString().substring(24)+".png";
            String imgurl =  BitmapUtil.saveImgToDisk(name,bitmap);
            info.imgurl = imgurl;
            info.username = defname;
            RecordList.add(info);
        }
        return RecordList;
    }
}